<!--20210421  zaq  新建修改密码界面-->

<template>
<div class="update_pwd">
  <el-form :model="ruleForm" status-icon :rules="check" ref="ruleForm" label-width="100px" class="demo-ruleForm">
    <el-form-item label="原密码" prop="name">
      <el-input  style="width: 90%" type="password" v-model.number="ruleForm.ex_pwd"></el-input>
    </el-form-item>

    <el-form-item label="新密码" prop="pass">
      <el-input style="width: 90%" type="password" v-model="ruleForm.pass" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item label="确认密码" prop="checkPass">
      <el-input style="width: 90%" type="password" v-model="ruleForm.checkPass"
                autocomplete="off"></el-input>
    </el-form-item>


  </el-form>
  <span slot="footer" class="dialog-footer">
      <el-button @click="update('ruleForm')">确定</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </span>
</div>
</template>

<script>
export default {
  name: "Update_pwd",
  data(){
    // 合法性判断
    var checkPwd = (rule, value, callback) => {
      //合法性判断
      if (!value) {
        return callback(new Error('密码不能为空'));
      }
    };
    var validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入密码'));
      } else {
        if (this.ruleForm.checkPass !== '') {
          this.$refs.ruleForm.validateField('checkPass');
        }
        callback();
      }
    };
    var validatePass2 = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'));
      } else if (value !== this.ruleForm.pass) {
        callback(new Error('两次输入密码不一致!'));
      } else {
        callback();
      }
    };
    return{
      ruleForm:{
        pass:'',
        checkPass:'',
        ex_pwd:''
      },
      check: {
        pass: [
          {validator: validatePass, trigger: 'blur'}
        ],
        checkPass: [
          {validator: validatePass2, trigger: 'blur'}
        ],
        ex_pwd: [
          {validator: checkPwd, trigger: 'blur'}
        ]
      }
    }
  },
  methods:{
    update(ruleForm){

    },//更新密码
    resetForm(ruleForm){
      this.$refs[ruleForm].resetFields();
    },//重置
  }
}
</script>

<style scoped>

</style>